package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddOperation implements IOPeration{
    @Override
    public void work(BookList bookList) {
        System.out.println("增加图书");
        if(bookList.isFull()){
            System.out.println("书架满了，不能新增了");
            return;
        }

        System.out.println("你要新增的书的书名为：");
        Scanner sc = new Scanner(System.in);
        String bookName = sc.nextLine();

        System.out.println("作者信息为：");
        String author = sc.nextLine();

        System.out.println("价格信息为：");
        int price = sc.nextInt();

        System.out.println("图书类型为：");
        String type = sc.nextLine();

        Book book = new Book(bookName, author, price, type);

        int number = bookList.getUsedSize();
        bookList.addBook(number,book);
        bookList.setUsedSize(number+1);

        System.out.println("新增图书成功");
    }
}
